<?php
require 'inc_security.php';
$type = 'payment';
$bg_success = '';
$db_config = new db_query('SELECT * FROM configuration WHERE con_type = "'.$type.'" LIMIT 1');
if(mysql_num_rows($db_config->result) == 0) {
   $db_c = new db_execute('INSERT INTO configuration(con_title,con_type,con_help) VALUES("Thanh toán","'.$type.'","Thanh toán")');
   $db_config = new db_query('SELECT * FROM configuration WHERE con_type = "'.$type.'" LIMIT 1');
}
$configDetail = mysql_fetch_assoc($db_config->result);
$configType = $configDetail['con_type'];
$configValue = json_decode(base64_decode($configDetail['con_value']),1);
$myform = new generate_form();
$myform->removeHTML(0);
$action = getValue('action','str','POST','');

if($action == 'execute'){
   $con_value = array();
   $con_value['content'] = prepare_text_article(getValue('content','str','POST',''));
   $con_value = base64_encode(json_encode($con_value));
   $myform->add('con_value','con_value',0,1,'');
   $myform->addTable($bg_table);
   $bg_errorMsg .= $myform->checkdata();
   if($bg_errorMsg == ''){
      $db_update = new db_execute($myform->generate_update_SQL('con_id',$configDetail['con_id']));
      unset($db_update);
      editSeoMeta($configDetail['con_id'],$bg_table);
      $bg_success = 'Cập nhật thành công !';
      $db_config = new db_query('SELECT * FROM configuration WHERE con_type = "'.$type.'" LIMIT 1');
      $configDetail = mysql_fetch_assoc($db_config->result);
      $configType = $configDetail['con_type'];
      $configValue = json_decode(base64_decode($configDetail['con_value']),1);
   }
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?=$load_header?>
</head>
<body>
<div class="page-heading">
   <h3>
       Bài viết thanh toán
   </h3>
   <ul class="breadcrumb">
       <li>
           <a href="#">Trang cố định</a>
       </li>
       <li class="active"> thanh toán </li>
   </ul>
</div>
<div class="wrapper">
<?php
if($bg_success != '') {
   ?>
   <div class="row">
       <div class="col-md-12">
           <section class="panel">
               <header class="panel-heading">
                   Thông báo trang thái
               </header>
               <div class="panel-body">
                  <div class="alert alert-success fade in">
                       <button type="button" class="close close-sm" data-dismiss="alert">
                           <i class="fa fa-times"></i>
                       </button>
                       <strong>Thành công!</strong> <?=$bg_success?>
                   </div>
               </div>
           </section>
       </div>
   </div>
   <?
}
?>
   <div class="row">
       <div class="col-md-12">
           <section class="panel">
               <header class="panel-heading">
                   Nội dung bài thanh toán
               </header>
               <div class="panel-body">
                  <?php $form = new form();?>
                  <?=$form->form_open()?>
                  <?=$form->tinyMCE('Nội dung', 
                                    'content', 
                                    'content', 
                                    $configValue['content'], 
                                    '100%'
                  )?>
                  <?=$form->seoMeta($bg_table,$configDetail['con_id'])?>
                  <div class="form-actions">
                     <input type="hidden" name="action" value="execute">
                     <button type="submit" name="redirect" value="1" class="btn btn-success">Lưu lại</button>&nbsp;
                     <button type="button" onclick="window.location='/admin/intro.php'" class="btn btn-danger">Thoát</button>&nbsp;
                  </div>
                  <?=$form->form_close()?>
               </div>
           </section>
       </div>
   </div>
</div>
</body>
</html>